home *** CD-ROM | disk | FTP | other *** search
/ PC Users 1998 November / Cd users extra 14.iso / prog / inst / mailc / status.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-14  |  1.9 KB  |  66 lines

  1. /*
  2. **  STATUS.C [edit EMAIL.H before compiling]
  3. **
  4. **  This program displays the header from each
  5. **  email message on the SMTP server.
  6. */
  7.  
  8. #include <windows.h>
  9. #include <stdio.h>
  10. #include "see.h"
  11. #include "email.h"
  12.  
  13. #define BUFF_SIZE   2048
  14. #define TEMP_SIZE    128
  15.  
  16. static char Buffer[BUFF_SIZE];
  17. static char Temp[TEMP_SIZE];
  18.  
  19. void ErrorExit(int Code)
  20. {seeErrorText(Code,(LPSTR)Buffer,512);
  21.  printf("SEE Error %d: %s\n", Code, Buffer);
  22.  seeClose();
  23.  exit(1);
  24. }
  25.  
  26. void main(int argc, char *argv[])
  27. {int i, n;
  28.  int Code;
  29.  int NbrMsg;
  30.  /* define diagnostics log file */
  31.  ///seeStringParam(SEE_LOG_FILE, (LPSTR)"from.log"); 
  32.  /* connect to POP3 server */
  33.  puts("Connecting...");
  34.  Code = seePop3Connect(
  35.     (LPSTR)POP3_HOST_NAME,             /* POP3 server */
  36.     (LPSTR)POP3_USER_NAME,             /* user */ 
  37.     (LPSTR)POP3_PASSWORD);             /* Password */
  38.  if(Code<0) ErrorExit(Code); 
  39.  /* get # messages waiting  */
  40.  puts("Getting message count...");
  41.  NbrMsg = seeGetEmailCount();                   
  42.  if(NbrMsg<0) ErrorExit(NbrMsg); 
  43.  printf("%d messages waiting.\n", NbrMsg);
  44.  /* read message headers */
  45.  for(i=1;i<=NbrMsg;i++)
  46.    {/* read message i */
  47.     printf("---[ Message %d ]------------------------------------\n",i);
  48.     Code = seeGetEmailLines(i, 0, (LPSTR)Buffer, BUFF_SIZE); 
  49.     if(Code<0) ErrorExit(Code);
  50.     ///Buffer[Code] = '\0';
  51.     /* display "DATE: " line */
  52.     n = seeExtractText((LPSTR)Buffer, "Date: ", (LPSTR)Temp, TEMP_SIZE);
  53.     if(n>0) printf("%s", (LPSTR)Temp);  
  54.     /* display "FROM: " line */
  55.     n = seeExtractText((LPSTR)Buffer, "From: ", (LPSTR)Temp, TEMP_SIZE);
  56.     if(n>0) printf("%s", (LPSTR)Temp);  
  57.     /* display "SUBJECT: " line */
  58.     n = seeExtractText((LPSTR)Buffer, "Subject: ", (LPSTR)Temp, TEMP_SIZE);
  59.     if(n>0) printf("%s", (LPSTR)Temp);
  60.    }
  61.  printf("----------------------------------------------------\n");
  62.  seeClose();
  63. } /* end main */
  64.  
  65.  
  66.